package leetcode.editor.cn.q1_300.q;

import java.util.HashMap;
import java.util.Map;

/**
 * @author qidi
 * @date 2021-11-10 15:25:11
 */
class Q0001_TwoSum {

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int[] twoSum(int[] nums, int target) {
            Map<Integer, Integer> map = new HashMap<>();
            int num;
            for (int i = 0; i < nums.length; i++) {
                num = nums[i];
                if (map.containsKey(target - num)) {
                    return new int[]{map.get(target - num), i};
                }
                map.put(num, i);
            }
            return null;
        }
    }
    //leetcode submit region end(Prohibit modification and deletion)


    public static void main(String[] args) {
        Solution solution = new Q0001_TwoSum().new Solution();
    }
}